package com.xyazm.inventory.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xyazm.inventory.domain.entity.ProductStockDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * <p>
 * 库存中心的商品库存表 Mapper 接口
 * </p>
 *
 * @author xuyou
 * @since 2022-06-04
 */
@Mapper
public interface ProductStockMapper extends BaseMapper<ProductStockDO> {

    /**
     * 锁定商品库存
     * @param skuCode
     * @param saleQuantity
     * @return
     */
    int lockProductStock(@Param("skuCode") String skuCode, @Param("saleQuantity") Integer saleQuantity);

    /**
     * 释放商品库存
     * @author xuyou
     * @date: 2022/7/1 14:05
     */
    int releaseProductStock(@Param("skuCode")String skuCode, @Param("saleQuantity") Integer saleQuantity);


    /**
     * 修改商品库存
     * @author xuyou
     * 2022/8/6 0006 23:10
     * @param skuCode
     * @param originSaleQuantity
     * @param saleIncremental
     * @return int
     */
    int modifyProductStock(@Param("skuCode") String skuCode,@Param("originSaleQuantity") Long originSaleQuantity, @Param("saleIncremental") Long saleIncremental);



    /**
     * 扣减销售库存
     * @author xuyou
     * 2022/8/6 0006 22:28
     * @param skuCode 商品编码
     * @param saleQuantity 销售库存
     * @return int
    */
    int deductSaleStock(@Param("skuCode") String skuCode, @Param("saleQuantity") Integer saleQuantity);


    /**
     * 增加已销售库存
     * @author xuyou
     * 2022/8/6 0006 22:32
     * @param skuCode
     * @param saleQuantity
     * @return int
    */
    int increaseSaledStock(@Param("skuCode") String skuCode, @Param("saleQuantity") Integer saleQuantity);


    /**
     * 还原销售库存
     * @author xuyou
     * 2022/8/6 0006 22:39
     * @param skuCode
     * @param saleQuantity
     * @return int
    */
    int restoreSaleStock(@Param("skuCode") String skuCode, @Param("saleQuantity") Integer saleQuantity);



}
